{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#quick_sort外部函数测试"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##导入quick_sort函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><img alt=\"Output\" src=\"\"></div>"
      ],
      "text/plain": [
       "LinkObject['/home/yangyongkang/文档/C_C-_WSTP_Example/Example/quick_sort/quick_sort', 189, \n",
       " \n",
       ">   2]"
      ]
     },
     "execution_count": 1,
     "metadata": {
      "text/html": [],
      "text/plain": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "link=Install[\"quick_sort\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 测试一个例子，检验正确性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><img alt=\"Output\" src=\"\"></div>"
      ],
      "text/plain": [
       "{0.142245, Null}"
      ]
     },
     "execution_count": 2,
     "metadata": {
      "text/html": [],
      "text/plain": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list=sort[testlist=RandomInteger[2^30-1,10^6]];//AbsoluteTiming"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><img alt=\"Output\" src=\"\"></div>"
      ],
      "text/plain": [
       "{0.061818, Null}"
      ]
     },
     "execution_count": 3,
     "metadata": {
      "text/html": [],
      "text/plain": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list1=Sort[testlist];//AbsoluteTiming"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><img alt=\"Output\" src=\"\"></div>"
      ],
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 4,
     "metadata": {
      "text/html": [],
      "text/plain": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list==list1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##复杂度分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "Needs[\"GeneralUtilities`\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><img alt=\"Output\" src=\"\"></div>"
      ],
      "text/plain": [
       "Legended[-Graphics-, Placed[PointLegend[{Directive[PointSize[0.0128333], \n",
       " \n",
       ">       AbsoluteThickness[1.6], RGBColor[0.790588, 0.201176, 0.]], \n",
       " \n",
       ">      Directive[PointSize[0.0128333], AbsoluteThickness[1.6], Opacity[0.5], \n",
       " \n",
       ">       RGBColor[0.790588, 0.201176, 0.]]}, {sort, Log[n] n}, \n",
       " \n",
       ">     LegendMarkers -> {{●, Small}, {, Automatic}}, Joined -> {False, True}, \n",
       " \n",
       ">     LabelStyle -> {}, LegendLayout -> Column], After, Identity]]"
      ]
     },
     "execution_count": 8,
     "metadata": {
      "text/html": [],
      "text/plain": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "BenchmarkPlot[sort,RandomInteger[2^30-1,#]&,Range[10000,500000,10000],\"IncludeFits\"->True]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Wolfram Language 12.1",
   "language": "Wolfram Language",
   "name": "wolframlanguage12.1"
  },
  "language_info": {
   "codemirror_mode": "mathematica",
   "file_extension": ".m",
   "mimetype": "application/vnd.wolfram.m",
   "name": "Wolfram Language",
   "pygments_lexer": "mathematica",
   "version": "12.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
